from google.appengine.ext import webapp

from google.appengine.api import users
import simplejson as json
from models import Locations

class JSONOut(webapp.RequestHandler):
    pass
#    def __init__(self):
#        self.response.headers['Content-Type'] = "application/json"


class LoginInfo(JSONOut):
    def get(self):
        loginInfo = {
            "is_manager" : users.is_current_user_admin()
        }
        self.response.out.write(json.dumps(loginInfo))

class LoginPage(webapp.RequestHandler):
    def get(self):
        url = users.create_login_url("/")
        self.redirect(url)

class QuincyInfo(JSONOut):
    def get(self):
        self.response.out.write(json.dumps(Locations.get_quincy()))

class WatertownInfo(JSONOut):
    def get(self):
        self.response.out.write(json.dumps(Locations.get_watertown()))
